import mongoose from '../config/DBHelper'
import moment from 'moment'
const Schema = mongoose.Schema
const CommentHandsSchema = new Schema({
  cid: { type: String, ref: 'comment' },
  uid: { type: String, ref: 'user' },
  created: { type: Date }
  // last_sign: { type: Date }
})

CommentHandsSchema.pre('save', function (next) {
  this.created = moment().format('YYYY-MM-DD HH:mm:ss')
  next()
})
CommentHandsSchema.statics = {
  findByUid (uid) {
    return this.findOne({
      uid
    }).sort({ created: -1 })
  }
}

const CommentHands = mongoose.model('comment_hands', CommentHandsSchema)

export default CommentHands
